#ifndef __KV_CONFIG_READER_IMP_H__
#define __KV_CONFIG_READER_IMP_H__

#include <string>

namespace KVConfig
{

    class Data;

    class ReaderImp
    {
    public:
        ReaderImp();
        virtual ~ReaderImp() {}

    public:
        void setKVSparator(char cKVSp);
        void setCommentSparator(char cCommentSp);

        bool parseString(const std::string &context, Data &data) const;
        bool parseFile(const std::string &file_name, Data &data) const;

    protected:
        std::string cutComment(const std::string &str) const;
        bool getKeyAndValue(const std::string &str, std::string& key, std::string& value) const;
        bool parseOneLine(const std::string &str, std::string& key, std::string& value) const;

    public:
        static int selfTest();
    protected:
        static int test_cutComment();
        static int test_parseOneLine();
        static int test_parseString();
        static int test_parseFile();

    private:
        char m_cKVSparator;
        char m_cCommentSparator;

        static const char * s_test_context;
    };
}

#endif //__KV_CONFIG_READER_IMP_H__
